package com.ybxy;

public class Test02 {
    public static void main(String[] args) {
        testA();
        testB();
        testC();
        testD();
    }
    public static void testA(){
        A a1 = new A(){
            public void show(String name, int age){
                System.out.println("name:" + name + " age:" + age);
            }
        };
        a1.show("张三", 25);
        A a2=(name,age) -> System.out.println("name:" + name + " age:" + age);
        a2.show("王五", 30);
        A a3=Test02::showA1;
        a3.show("李四", 20);
        A a4=new Test02()::showA2;
        a4.show("宋四", 10);

    }
    public static void testB(){
        B b1=new B(){
            public void show(String name){
                System.out.println("name=" + name);
            }
        };
        b1.show("李四");
        B b2=name -> System.out.println("name=" + name);
        b2.show("张三");


    }
    public static void testC(){
        C c1=new C(){
            public String show(String name){
               return "name=" + name;
            }
        };
        String result1=c1.show("张三");
        System.out.println(result1);
        C c2=name -> "name=" + name;
        String result2=c2.show("李四");
        System.out.println(result2);

    }
    public static void testD(){
        D d1=new D(){
            public int max(int a, int b){
                return a>b?a:b;
            }
        };
        System.out.println(d1.max(10, 20));
        D d2=(a,b) -> a>b?a:b;
        System.out.println(d2.max(30, 40));
        D d3=Math::max;
        System.out.println(d3.max(50, 60));
    }

    public static void showA1(String name, int age){
        System.out.println("name:" + name + " age:" + age);
    }
    public  void showA2(String name, int age){
        System.out.println("name:" + name + " age:" + age);
    }
}
